/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.kamai.client.upload;

import com.edu.kamai.config.Constant;
import com.edu.kamai.utility.FileOperation;
import java.io.File;

/**
 *
 * @author xyzhu
 */
public class UploadPaper extends Thread{
    public UploadPaper(){
    }
    
    private void upLoadPaper(String fn){
        fileName = fn;
    }
    
    private String getPaperFullName(){
        File directory = new File("."); 
        String path = "";
        try{
            path = directory.getCanonicalPath();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return path + "\\" + fileName + ".xml";
    }
    
    @Override
    public void run() {
        String url = Constant.upLoadUrl;
        String paperName = getPaperFullName();
        PostFile p = new PostFile(paperName, url);
        try{
            p.uploadFile();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        //delete file
        
        System.out.println("paperName:" + paperName);
        FileOperation.deleteFile(paperName);
    }
    
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
    
    private String fileName;

    /*
    public static void main(String[] arg){
        
    }
     * 
     */
}
